#include "../include/kasm.h"
#include "../include/defs.h"
#include "../include/teclado.h"
#include "../include/bufferTeclado.h"
#include "../include/buffer.h"
#include "../include/video.h"
#include "../include/mouse.h"
#include "../include/protpant.h"
#include "../include/kernel.h"
#include "../include/shell.h"


void 
shell(void){
		int c, i, j;
		char output[2000];
		int flag;
		int cant = 0;
		while(1)
		{
			if ( !BufferTecladoEmpty() )
			{
				c = getchar();
				if(  c == 8 ||  isAlphanum(c) || c == '\n' ||  c== ' ')
				{
					if (c == 8)
					{
						if (!BufferIsEmpty())
						{
							RwdCursor();
							putchar(' '); /*Back space*/
							RwdCursor();
							RemoveKey();
						}
					}
				if ( !BufferIsFull())
				{
					if (c != 8)
						{
							if(c != '\n')
								putchar(c);
							InsertKey(c);
						}
					if (BufferIsReady() )
					{
						i = FlushBuffer(output);

						command(output);
						prompt();
					}
					else
					;
				}
				else {
					print("Buffer Full\n");
					FlushBuffer(output);
					command(output);
					prompt();

				}
				}
			}
		}
}
 
